using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text;
using System.Data; 
using yq.IBase; 
using yq.Dictionary; 
using yq.Basis; 
using yq.Model.Logic;
using System.Collections; 
using Db; 
using System.Data.Common;

namespace yq.Model.Base 
{
    ///<summary>
    /// Know_List - 知道 - 对象基础类
    /// </summary>
    ///<typeparam name="T"></typeparam>
    public abstract class IKnowList<T> :ModelBase<KnowList> where T : KnowList, new()
    {
        /// <summary>
        /// 写入主键值
        /// </summary>
        /// <param name="Id">主键</param>
        protected internal override void SetKeyValue(dynamic Id)
        {
            this.KnowId = Id;
        }

        /// <summary>
        /// 获取主键值
        /// </summary>
        /// <returns></returns>
        protected internal override dynamic GetKeyValue()
        {
            return KnowId;
        }

        /// <summary>
        /// 为本对象赋值
        /// </summary>
        /// <param name="dy"></param>
        public override void SetValue(dynamic dy) 
        {
           this.KnowId=dy.KnowId;
           this.PathId=dy.PathId;
           this.UserId=dy.UserId;
           this.Title=dy.Title;
           this.ContentId=dy.ContentId;
           this.HttpSource=dy.HttpSource;
           this.GoodContentId=dy.GoodContentId;
           this.Status=dy.Status;
           this.Version=dy.Version;
        } 

        #region 定义属性

     
         /// <summary>
        /// 知道ID
        /// </summary>
        private String _KnowId = "";
      
        /// <summary>
        /// 知道ID
        /// </summary>
        public String KnowId
        {
            get 
            {
              return   (this._KnowId); 
            }

            set 
            {
                    _KnowId= value;  
            }
        }
       
     
         /// <summary>
        /// 目录ID
        /// </summary>
        private String _PathId = "";
      
        /// <summary>
        /// 目录ID
        /// </summary>
        public String PathId
        {
            get 
            {
              return   (this._PathId); 
            }

            set 
            {
                    _PathId= value;  
            }
        }
       
     
         /// <summary>
        /// 用户ID
        /// </summary>
        private String _UserId = "";
      
        /// <summary>
        /// 用户ID
        /// </summary>
        public String UserId
        {
            get 
            {
              return   (this._UserId); 
            }

            set 
            {
                    _UserId= value;  
            }
        }
       
     
         /// <summary>
        /// 标题
        /// </summary>
        private String _Title = "";
      
        /// <summary>
        /// 标题
        /// </summary>
        public String Title
        {
            get 
            {
              return   (this._Title); 
            }

            set 
            {
                    _Title= value;  
            }
        }
       
     
         /// <summary>
        /// 内容
        /// </summary>
        private String _ContentId = "";
      
        /// <summary>
        /// 内容
        /// </summary>
        public String ContentId
        {
            get 
            {
              return   (this._ContentId); 
            }

            set 
            {
                    _ContentId= value;  
            }
        }
       
     
         /// <summary>
        /// 参考来源
        /// </summary>
        private String _HttpSource = "";
      
        /// <summary>
        /// 参考来源
        /// </summary>
        public String HttpSource
        {
            get 
            {
              return   (this._HttpSource); 
            }

            set 
            {
                    _HttpSource= value;  
            }
        }
       
     
         /// <summary>
        /// 最佳答案ID
        /// </summary>
        private String _GoodContentId = "";
      
        /// <summary>
        /// 最佳答案ID
        /// </summary>
        public String GoodContentId
        {
            get 
            {
              return   (this._GoodContentId); 
            }

            set 
            {
                    _GoodContentId= value;  
            }
        }
       
     
         /// <summary>
        /// 状态
        /// </summary>
        private int _Status =-1;
      
        /// <summary>
        /// 状态
        /// </summary>
        public yq.Enums.KnowList.Status Status
        {
            get 
            {
              return   (yq.Enums.KnowList.Status)this._Status;  
            }

            set 
            {
                    _Status= value.GetHashCode(); 
            }
        }
       
     
        
       

      #endregion 定义属性 

          protected internal override void SetValue(KnowList info, DataRow row) 
          { 
               if (row == null) 
               { 
                 info.IsLoad = false; 
               }
               else 
               { 
                  info.IsLoad = true; 
                  
                  if(row["KnowId"]!= DBNull.Value)
                  {
                  info.KnowId=row["KnowId"].ToString();
                 }
                 
                  
                  if(row["PathId"]!= DBNull.Value)
                  {
                  info.PathId=row["PathId"].ToString();
                 }
                 
                  
                  if(row["UserId"]!= DBNull.Value)
                  {
                  info.UserId=row["UserId"].ToString();
                 }
                 
                  
                  if(row["Title"]!= DBNull.Value)
                  {
                  info.Title=row["Title"].ToString();
                 }
                 
                  
                  if(row["ContentId"]!= DBNull.Value)
                  {
                  info.ContentId=row["ContentId"].ToString();
                 }
                 
                  
                  if(row["HttpSource"]!= DBNull.Value)
                  {
                  info.HttpSource=row["HttpSource"].ToString();
                 }
                 
                  
                  if(row["GoodContentId"]!= DBNull.Value)
                  {
                  info.GoodContentId=row["GoodContentId"].ToString();
                 }
                 
                  
                  if(row["Status"]!= DBNull.Value)
                  {
                  info.Status=  (yq.Enums.KnowList.Status)(row["Status"]) ;
                 }
                 
                  
                  if(row["Version"]!= DBNull.Value)
                  {
                  info.Version=row["Version"].ToString();
                 }
                 
               } 

          } 

        protected internal override void GetDbParameters(DbCommand comm, KnowList info, DbHelper cn) 
        { 
             
                cn.AddInParameter(comm, "@KnowId", DbType.String,ParameterTool.GetObj( info._KnowId )); 
            
             
                cn.AddInParameter(comm, "@PathId", DbType.String,ParameterTool.GetObj( info._PathId )); 
            
             
                cn.AddInParameter(comm, "@UserId", DbType.String,ParameterTool.GetObj( info._UserId )); 
            
             
                cn.AddInParameter(comm, "@Title", DbType.String,ParameterTool.GetObj( info._Title )); 
            
             
                cn.AddInParameter(comm, "@ContentId", DbType.String,ParameterTool.GetObj( info._ContentId )); 
            
             
                cn.AddInParameter(comm, "@HttpSource", DbType.String,ParameterTool.GetObj( info._HttpSource )); 
            
             
                cn.AddInParameter(comm, "@GoodContentId", DbType.String,ParameterTool.GetObj( info._GoodContentId )); 
            
             
                cn.AddInParameter(comm, "@Status", DbType.Int32,ParameterTool.GetObj( info._Status )); 
            
                
                cn.AddInParameter(comm,"@Version", DbType.String, Guid.NewGuid().ToString());
              

                cn.AddInParameter(comm,"@_versionOdl", DbType.String, info._Version); 
                 
        } 

    } 
} 